<script setup>
import {saveApi} from "@/api/AssetsApi";
import MyForm from "@/components/MyForm.vue";
import {shallowReactive, shallowRef} from "vue";
import {RULE} from "@/const";
import MyNav from "@/components/MyNav.vue";
import router from "@/router";
import {dateFormat} from "@/util";

let arr = [];
// 表单项
let items = shallowRef([
  {'label': '资产名称', 'prop': 'title', 'required': 'true', 'span': '12'},
 /* {'label': '资产图片', 'prop': 'picture', 'required': 'true', 'span': '12'},*/
  {'label': '资产单价', 'prop': 'price', 'required': 'true', 'span': '12', 'type':'number'},
  {'label': '单价单位', 'prop': 'priceUnit', 'required': 'true', 'span': '12'},
  {'label': '剩余库存', 'prop': 'stock', 'required': 'true', 'span': '12', 'type':'number'},
  {'label': '总计库存', 'prop': 'total', 'required': 'true', 'span': '12', 'type':'number'},
  {'label': '库存单位', 'prop': 'stockUnit', 'required': 'true', 'span': '12'},
  {'label': '资产描述', 'prop': 'info', 'type': 'card'},
]);
// 表单默认值
let data = shallowReactive({});
// 表单规则
let rules = {
  'info': RULE.COMMON_INFO,
  'title': RULE.COMM_TITLE,
};


</script>

<template>

  <my-nav :items="[
  {'icon': 'User', 'label': '资产管理'},
  {'icon': 'User', 'label': '资产列表', 'url': '/rms/Assets'},
  {'icon': 'User', 'label': '添加资产'},
]"/>

  <el-divider/>
  <my-form type="insert"
           :items="items"
           :data="data"
           :rules="rules"
           :api="saveApi"
           :fn="() => router.push('/rms/Assets')"
           :span="2"/>

</template>

<style scoped lang="scss">

</style>